﻿namespace Sidvall.AuthorizationManager.Data.Entity.Entities
{
    public partial class AuthorizationScope : global::Sidvall.Data.DataRowBase, global::Sidvall.AuthorizationManager.Data.IAuthorizationScope
    {
        #region Public Members

        #region AuthorizationScopeId

        private long _AuthorizationScopeId;
        public long AuthorizationScopeId
        { 
            get
            {
                return _AuthorizationScopeId;
            }
            set
            {
                _AuthorizationScopeId = value;
            }
        }

        #endregion
        #region DefaultResourceActionAccessLevel

        private int _DefaultResourceActionAccessLevel;
        public int DefaultResourceActionAccessLevel
        { 
            get
            {
                return _DefaultResourceActionAccessLevel;
            }
            set
            {
                _DefaultResourceActionAccessLevel = value;
            }
        }

        #endregion
        #region DefaultResourceItemAccessLevel

        private int _DefaultResourceItemAccessLevel;
        public int DefaultResourceItemAccessLevel
        { 
            get
            {
                return _DefaultResourceItemAccessLevel;
            }
            set
            {
                _DefaultResourceItemAccessLevel = value;
            }
        }

        #endregion
        #region DefaultUserContext

        private string _DefaultUserContext;
        public string DefaultUserContext
        { 
            get
            {
                return _DefaultUserContext;
            }
            set
            {
                _DefaultUserContext = value;
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled;
        public bool IsEnabled
        { 
            get
            {
                return _IsEnabled;
            }
            set
            {
                _IsEnabled = value;
            }
        }

        #endregion
        #region MissingUserPolicyId

        private int _MissingUserPolicyId;
        public int MissingUserPolicyId
        { 
            get
            {
                return _MissingUserPolicyId;
            }
            set
            {
                _MissingUserPolicyId = value;
            }
        }

        #endregion
        #region Name

        private string _Name;
        public string Name
        { 
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        #endregion
        #region RequireActiveUser

        private bool _RequireActiveUser;
        public bool RequireActiveUser
        { 
            get
            {
                return _RequireActiveUser;
            }
            set
            {
                _RequireActiveUser = value;
            }
        }

        #endregion
        #region ResourceItemPolicyId

        private int _ResourceItemPolicyId;
        public int ResourceItemPolicyId
        { 
            get
            {
                return _ResourceItemPolicyId;
            }
            set
            {
                _ResourceItemPolicyId = value;
            }
        }

        #endregion
        
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.AuthorizationManager.Data.Entity.Entities.AuthorizationScopeExport> AuthorizationScopeExport { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.AuthorizationManager.Data.Entity.Entities.AuthorizationScopeResourceAction> AuthorizationScopeResourceAction { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.AuthorizationManager.Data.Entity.Entities.AuthorizationScopeResourceItem> AuthorizationScopeResourceItem { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual System.Collections.Generic.ICollection<Sidvall.AuthorizationManager.Data.Entity.Entities.AuthorizationScopeUser> AuthorizationScopeUser { get; set; }
        
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.AuthorizationManager.Data.Entity.SystemContext.Current.EntityFacade.AuthorizationScopeManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.AuthorizationManager.Data.Entity.SystemContext.Current.EntityFacade.AuthorizationScopeManager.DataRowStateIsDirty(this);
            }
        }

        #endregion

        #region IAuthorizationScope Members

        System.Nullable<long> global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.AuthorizationScopeId
        {
            get
            {
                return this._AuthorizationScopeId;
            }
            set
            {
                if (value != null)
                    this.AuthorizationScopeId = value.Value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.AuthorizationScopeAccessLevel global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.DefaultResourceActionAccessLevel
        {
            get
            {
                return (global::Sidvall.AuthorizationManager.Data.AuthorizationScopeAccessLevel)this._DefaultResourceActionAccessLevel;
            }
            set
            {
                this.DefaultResourceActionAccessLevel = (int)value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.AuthorizationScopeAccessLevel global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.DefaultResourceItemAccessLevel
        {
            get
            {
                return (global::Sidvall.AuthorizationManager.Data.AuthorizationScopeAccessLevel)this._DefaultResourceItemAccessLevel;
            }
            set
            {
                this.DefaultResourceItemAccessLevel = (int)value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.DefaultUserContext
        {
            get
            {
                return this._DefaultUserContext;
            }
            set
            {
                this.DefaultUserContext = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this.IsEnabled = value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.MissingUserPolicy global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.MissingUserPolicyId
        {
            get
            {
                return (global::Sidvall.AuthorizationManager.Data.MissingUserPolicy)this._MissingUserPolicyId;
            }
            set
            {
                this.MissingUserPolicyId = (int)value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this.Name = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.RequireActiveUser
        {
            get
            {
                return this._RequireActiveUser;
            }
            set
            {
                this.RequireActiveUser = value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.ResourceItemActionPolicy global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.ResourceItemPolicyId
        {
            get
            {
                return (global::Sidvall.AuthorizationManager.Data.ResourceItemActionPolicy)this._ResourceItemPolicyId;
            }
            set
            {
                this.ResourceItemPolicyId = (int)value;
            }
        }
        System.Nullable<System.Int32> global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.ServerConnectionId
        {
            get
            {
                return null;
            }
            set
            {
            }
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IAuthorizationScopeExport> global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.AuthorizationScopeExports
        {
            get
            {
                return this.AuthorizationScopeExport;
            }
        }
        void global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.SetAuthorizationScopeExports(Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeExport> items)
        {
            this.AuthorizationScopeExport = items as AuthorizationScopeExportCollection;
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IAuthorizationScopeResourceAction> global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.AuthorizationScopeResourceActions
        {
            get
            {
                return this.AuthorizationScopeResourceAction;
            }
        }
        void global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.SetAuthorizationScopeResourceActions(Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction> items)
        {
            this.AuthorizationScopeResourceAction = items as AuthorizationScopeResourceActionCollection;
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IAuthorizationScopeResourceItem> global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.AuthorizationScopeResourceItems
        {
            get
            {
                return this.AuthorizationScopeResourceItem;
            }
        }
        void global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.SetAuthorizationScopeResourceItems(Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceItem> items)
        {
            this.AuthorizationScopeResourceItem = items as AuthorizationScopeResourceItemCollection;
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
        System.Collections.Generic.IEnumerable<IAuthorizationScopeUser> global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.AuthorizationScopeUsers
        {
            get
            {
                return this.AuthorizationScopeUser;
            }
        }
        void global::Sidvall.AuthorizationManager.Data.IAuthorizationScope.SetAuthorizationScopeUsers(Sidvall.Data.IDataRowProvider<global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeUser> items)
        {
            this.AuthorizationScopeUser = items as AuthorizationScopeUserCollection;
        }

        #endregion

        #endregion
        #region Constructors

        public AuthorizationScope() : this(false, null, null)
        {
        }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public AuthorizationScope(bool initializeChildren, Sidvall.Data.IDataRowContextProvider context, Sidvall.Data.DataRowState? dataRowState)
        {
            if ((context != null) || (dataRowState != null))
                SetDataRowContext(context, dataRowState);
            if (initializeChildren)
            {
                this.AuthorizationScopeExport = new System.Collections.Generic.List<AuthorizationScopeExport>();
                this.AuthorizationScopeResourceAction = new System.Collections.Generic.List<AuthorizationScopeResourceAction>();
                this.AuthorizationScopeResourceItem = new System.Collections.Generic.List<AuthorizationScopeResourceItem>();
                this.AuthorizationScopeUser = new System.Collections.Generic.List<AuthorizationScopeUser>();
            }
        }

        #endregion
    }
}